package com.alibaba.shopping_admin_service.service;

import com.alibaba.shopping_admin_service.mapper.PermissionMapper;
import com.alibaba.shopping_common.pojo.Permission;
import com.alibaba.shopping_common.service.PermissionService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName PermissionImpl
 * @Description TODO
 * @Author Leo
 * @Date 2024/12/6 16:06
 */
@DubboService
@Transactional
public class PermissionImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    // 新增权限信息
    @Override
    public void addPermission(Permission permission) {
        permissionMapper.insert(permission);
    }

    // 更新权限信息
    @Override
    public void updatePermission(Permission permission) {
        System.out.println("updatePermission"+permission);
        permissionMapper.updateById(permission);
    }

    // 删除权限信息
    @Override
    public void delPermission(Long pid) {
        permissionMapper.deleteById(pid);
    }

    // 根据ID查询permission信息
    @Override
    public Permission findById(Long pid) {
        return permissionMapper.selectById(pid);
    }

    // 分页查询
    @Override
    public Page<Permission> search(int page, int size) {
        return permissionMapper.selectPage(new Page<>(page,size),null);
    }

    // 查询所有的权限信息
    @Override
    public List<Permission> findAll() {
        return permissionMapper.selectList(null);
    }
}




